package pipeline.fragment;

import pipeline.misc.Fragment;
import pipeline.misc.FrameBuffer;

/**
 * This fragment processor will place the indicated color into the framebuffer
 * only if the fragment passes the z buffer test (ie - it isn't occluded by
 * another fragment).
 *
 * @author ags
 */
public class ColorZBufferFP extends FragmentProcessor
{
        public int nAttr()
        {
                return 3;
        }
       
        public void fragment(Fragment frag, FrameBuffer frameb)
        {
                float z = frag.attrs[0];
               
                if(z <= frameb.getZ(frag.x, frag.y)) {
                	frameb.set(frag.x, frag.y, frag.attrs[1], frag.attrs[2], frag.attrs[3], z);
                }
        }
}

